from requests import Response


class AssertionUtil:
    """
        接口断言工具
    """
    @classmethod
    def assert_status(cls, actual_response: Response, except_status_code: int):
        """断言请求响应状态码"""
        print(f"预期结果: {except_status_code}")
        print(f"实际结果: {actual_response.status_code}")
        assert actual_response.status_code == except_status_code, f"响应状态码断言失败: 预期{except_status_code} - 实际{actual_response.status_code}"
    
    @classmethod
    def assert_eq(cls, actual_response: Response, except_data: dict):
        """断言相等"""
        for key, value in except_data.items():
            print(f"预期结果: {value}")
            print(f"实际结果: {actual_response.json().get(key)}")
            assert actual_response.json().get(key) == value, f"相等断言{key}失败: 预期{actual_response.json().get(key)} - 实际{value}"
    
    @classmethod
    def assert_contains(cls, actual_response: Response, excetion: dict):
        """断言包含"""
        pass
